<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>Untitled Page</title>
        <meta name="generator" content="WYSIWYG Web Builder 8 - http://www.wysiwygwebbuilder.com">
        <link rel="stylesheet" href="adminCss/WebBuilder.css" />
        <script type="text/javascript" src="adminScript/myAdminTableScript.js"></script>
        <script type="text/javascript" src="adminScript/myAdminScript.js"></script>
        <script type="text/javascript">
            function fnAddSupplier() {
                // cek, add atau update
                vUpdate = document.getElementById('txtUpdate').value;
                if (vUpdate == '') {
                    document.formAdmin.method = 'POST';
                    document.formAdmin.action = 'adminLogic/AdminSupplier_Add.php';
                    document.formAdmin.submit();
                } else if (vUpdate == '1') {
                    vUpdateId = document.getElementById('txtUpdateID').value;
                    fnUpdateSupplier(vUpdateId);
                }
            }
            
            function fnUpdateSupplier(vIdBarang) {
                vUpdate = document.getElementById('txtUpdate').value;
                document.getElementById('hidUpdate').value = vUpdate;
                document.getElementById('hidUpdateID').value = vIdBarang;

                document.formAdmin.method = 'POST';
                document.formAdmin.action = 'adminLogic/AdminSupplier_Update.php';
                document.formAdmin.submit();
            }
        </script>
    </head>
    <body>
        <form name="formAdmin">
            <input type="hidden" name="hidCurPage" id="hidCurPage" />
            <input type="hidden" name="hidTotalPage" id="hidTotalPage" />
            <input type="hidden" name="hidStartNum" id="hidStartNum" />
            <input type="hidden" name="hidEndNum" id="hidEndNum" />
            <input type="hidden" name="hidNCounter" id="hidNCounter" />
            <input type="hidden" name="hidPageName" id="hidPageName" value="mstSupplier.php"/>
            
            <input type="text" style="display: none" name="hidUpdate" id="hidUpdate" />
            <input type="text" style="display: none" name="hidUpdateID" id="hidUpdateID" />
            <?php
            include("../utility/connection.php");
            include("../utility/general.php");
            include("../model/mSupplier.php");
            @session_start();
//            unset($_SESSION['startNum']);
//            unset($_SESSION['endNum']);
//            unset($_SESSION['curPage']);
            $kodeUbah = '';
            $idBarang = '';
            $Nama = '';
            $Alamat = '';
            $Telp = '';
            $Email = '';
            if (isset($_SESSION['ubah'])) {
                $kodeUbah = $_SESSION['ubah'];
                $idBarang = $_SESSION['idBarang'];
                $detilBarang = $_SESSION['detilBarang'];
                
                $Nama = $detilBarang[0];
                $Alamat = $detilBarang[1];
                $Telp = $detilBarang[2];
                $Email = $detilBarang[3];
            }
            ?>
            <div id="wb_Text2" style="position:absolute;left:20px;top:80px;width:130px;height:16px;z-index:0;">
                <span style="color:#000000;font-family:Arial;font-size:13px;">Nama</span></div>
            <input type="text" id="Editbox1" style="position:absolute;left:160px;top:80px;width:248px;height:18px;line-height:18px;z-index:1;" 
                   name="Editbox1" value="<?php echo $Nama ?>">
            <div id="wb_Text1" style="position:absolute;left:20px;top:110px;width:130px;height:16px;z-index:2;">
                <span style="color:#000000;font-family:Arial;font-size:13px;">Alamat</span></div>
            <input type="text" id="Editbox2" style="position:absolute;left:160px;top:110px;width:248px;height:18px;line-height:18px;z-index:3;" 
                   name="Editbox2" value="<?php echo $Alamat ?>">
            <div id="wb_Text3" style="position:absolute;left:20px;top:140px;width:130px;height:16px;z-index:4;">
                <span style="color:#000000;font-family:Arial;font-size:13px;">Telepon</span></div>
            <input type="text" id="Editbox3" style="position:absolute;left:160px;top:140px;width:248px;height:18px;line-height:18px;z-index:5;" 
                   name="Editbox3" value="<?php echo $Telp ?>">
            <div id="wb_Text4" style="position:absolute;left:20px;top:170px;width:130px;height:16px;z-index:6;">
                <span style="color:#000000;font-family:Arial;font-size:13px;">Email</span></div>
            <input type="text" id="Editbox4" style="position:absolute;left:160px;top:170px;width:248px;height:18px;line-height:18px;z-index:7;" 
                   name="Editbox4" value="<?php echo $Email ?>">
            
            <input type="submit" onclick="fnAddSupplier()" id="Button1" name="Button1" value="Submit" style="position:absolute;left:20px;top:210px;width:96px;height:25px;z-index:8;">
            <input type="reset" id="Button2" name="Button2" value="Batal" style="position:absolute;left:120px;top:210px;width:96px;height:25px;z-index:9;">
            
            <div id="wb_Text10" style="position:absolute;left:20px;top:10px;width:500px;height:51px;z-index:10;">
                <span style="color:#000000;font-family:Arial;font-size:43px;"><strong>Administrasi Supplier</strong></span></div>
        </form>
        <div style="position:absolute;left:20px;top:250px;z-index:21;">
            <?php
            $resAllBarang = fnAllSupplier();
            if ((isset($_SESSION['startNum'])) && (isset($_SESSION['endNum']))) {
                $startNum = $_SESSION['startNum'];
                $endNum = $_SESSION['endNum'];
                $resAllBarang = fnAllSupplierByRange($startNum, $endNum);
            }

            $TotalBarang = fnAllSupplier();
            $TotalRow = mysql_num_rows($TotalBarang);
            include("tablePage.php");
            ?>
        </div>
    </body>
</html>